<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>{$site_name}</title>
    <!-- CSS -->
    <link rel="stylesheet" href="{url:#css/materialize.min.css}"/>
    <link rel="stylesheet" href="{url:#css/me.css}"/>
    <link rel="stylesheet" href="{url:#css/iconfont.css}"/>

    <style type="text/css">
        /**去除绿色下划线 - 开始*/
        input::-webkit-input-placeholder {
            color: #7e7e7e;
            text-indent: 5px;
        }

        input:not([type]), input[type=text], input[type=password], input[type=email], input[type=url], input[type=time], input[type=date], input[type=datetime-local], input[type=tel], input[type=number], input[type=search], textarea.materialize-textarea {
            background-color: transparent;
            border: none;
            border-radius: 0;
            outline: none;
            height: 1.5em;
            width: 100%;
            font-size: 1rem;
            margin: 0;
            padding: 0;
            box-shadow: none;
        }

        input:not([type]):focus:not([readonly]), input[type=text]:focus:not([readonly]), input[type=password]:focus:not([readonly]), input[type=email]:focus:not([readonly]), input[type=url]:focus:not([readonly]), input[type=time]:focus:not([readonly]), input[type=date]:focus:not([readonly]), input[type=datetime-local]:focus:not([readonly]), input[type=tel]:focus:not([readonly]), input[type=number]:focus:not([readonly]), input[type=search]:focus:not([readonly]), textarea.materialize-textarea:focus:not([readonly]) {
            border-bottom: none;
            box-shadow: none
        }

        /**去除绿色下划线 - 结束*/
        .q-ltitle {
            height: 37px;
            line-height: 37px;
            vertical-align: middle;
            font-family: "微软雅黑";
            font-size: 16px;
            text-align: center;
        }
    </style>
    <!-- JS -->
    <script src="{url:#js/jquery-1.11.3.min.js}"></script>
    <script src="{url:#js/materialize.min.js}"></script>
    <script src="{url:#js/home/register.js}"></script>
</head>
<body class="q-body">
<!-- TitleBar 开始 -->
<div class="navbar-fixed">
    <nav>
        <div class="nav-wrapper red accent-4 valign-wrapper">
            <ul class="left" id="nav-btn-left">
                <li><a href="{url:/mobile/user_center}"><i class="iconfont">&#xe63c;</i></a></li>
            </ul>
            <span class="title-bar-size center_align">申请成为商家</span>
            <ul class="right">
                <li><a class="disabled" style="visibility:hidden"><i class="iconfont">&#xe63c;</i></a></li>
            </ul>
        </div>
    </nav>
</div>
<!-- TitleBar 结束 -->

<div class="container" style="padding-top: 30px;">
{if:!empty($dp_obj) && $dp_obj['is_ok']==0}
	<center style="font-size:22px;">您的申请已提交，请等待系统审核</center>
{else:}
    <form method="post" action="{url:/mobile/add_dp}" enctype="multipart/form-data">
        <div class="row">
            <div class="col s4 q-ltitle">店铺名称：</div>
            <div class="col s7">
                <input name="dp_name" id="dp_name" type="text" placeholder="企业或店铺名称"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;height: 15px;"/>
            </div>
        </div>

        <div class="row">
            <div class="col s4 q-ltitle">机构代码：</div>
            <div class="col s7">
                <input name="dp_dm" id="dp_dm" type="text" placeholder="企业或店铺机构名称"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;height: 15px;"/>
            </div>
        </div>

        <div class="row">
            <div class="col s4 q-ltitle">联系电话：</div>
            <div class="col s7">
                <input name="dp_tel" id="dp_tel" type="text" placeholder="手机或座机"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;height: 15px;"/>
            </div>
        </div>

        <div class="row">
            <div class="col s4 q-ltitle">店铺图片：</div>
            <div class="col s7">
                <input name="dp_logo" id="dp_logo" type="file" placeholder="手机或座机"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;width: 100%;"/>
            </div>
        </div>

		<div class="row">
            <div class="col s4 q-ltitle">营业执照：</div>
            <div class="col s7">
                <input name="dp_pic" id="dp_pic" type="file" placeholder="手机或座机"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;width: 100%;"/>
            </div>
        </div>
        
        
        <div class="row">
            <div class="col s4 q-ltitle">行业类别：</div>
            <div class="col s7">
                <select class="browser-default" name="category_id" id="category_id" style="margin-left:-10px;">
                	{query:name=goods_category where=parent_id eq 0}
                    <option value="{$item[id]}">{$item['name']}</option>
                    {/query}
                </select>
            </div>
        </div>
        <div class="addr-item q-ltitle" style="width: 100%;text-align: left;">
            店铺或企业所在地址:
        </div>
        <div class="row">
            <div class="col s4">
                <select class="browser-default" id="province" name="province" onchange="change_city(this)">
                    <option value="0">选择省</option>
                    {query:name=area where=parent_id eq 0}
                    	<option value="{$item['id']}">{$item['name']}</option>
                    {/query}
                    
                </select>
            </div>
            <div class="col s4">
                <select class="browser-default" id="city" name="city" onchange="change_county(this)">
                    <option value="0">选择市</option>
                    
                </select>
            </div>
            <div class="col s4">
                <select class="browser-default" id="county" name="county">
                    <option value="0">选择县/区</option>
                </select>
            </div>
        </div>        
        <div class="row">
            <div class="col s4 q-ltitle">详细地址：</div>
            <div class="col s7">
                <input name="dp_addr" id="dp_addr" type="text" placeholder="详细地址"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;height: 15px;"/>
            </div>
        </div>
        
        
        <div class="row">
            <div class="col s4 q-ltitle">简介：</div>
            <div class="col s7">
            	<textarea name="dp_content" id="dp_content" style="border:1px solid #ccc;padding:10px; margin-left:-10px;width: 120%;height:100px;"></textarea>
            <!-- 
                <input type="text"
                       style="border:1px solid #ccc;padding:10px; margin-left:-10px;width: 100%;"/>
                       -->
            </div>
        </div>

        <div class="center clearfix" style="margin-right:10px; margin-left:10px;margin-top:60px;">
        <!-- 
                    <a class="waves-effect waves-light btn-large red z-depth-0 login_btn">提交申请</a>
        -->
        <input type="hidden" name="user_id" value="{$mobile_user[id]}"/>
            <input type="submit" value="提交申请" onclick="return sub()" class="waves-effect waves-light btn-large red z-depth-0 login_btn"/>
        </div>
    </form>
 {/if}
</div>


<script type="text/javascript">

function sub()
{
	//店铺名称
	var dp_name = $("#dp_name").val();
	var dp_dm   = $("#dp_dm").val(); 
	var dp_tel  = $("#dp_tel").val();
	var dp_logo = $("#dp_logo").val();
	//营业执照
	var dp_pic  = $("#dp_pic").val();
	//行业类别
	var category_id = parseInt($("#category_id").val());
	var province    = parseInt($("#province").val());
	var city        = parseInt($("#city").val());
	var county      = parseInt($("#county").val());
	var dp_content  = $("#dp_content").val();
	
	if(dp_name == '')
	{
		alert('店铺名称不能为空');
		return false;
	}
	
	if(dp_dm == '')
	{
		alert('机构代码不能为空');
		return false;
	}
	
	if(dp_tel == '')
	{
		alert('电话不能为空');
		return false;
	}
	
	if(dp_logo == '')
	{
		alert('店铺图片不能为空');
		return false;
	}
	
	if(dp_pic == '')
	{
		alert('营业执照不能为空');
		return false;
	}
	
	if(province == 0 || city == 0 || county == 0)
	{
		alert('请选择完整的地址');
		return false;
	}
	
	var dp_addr = $("#dp_addr").val();
	if(dp_addr == '')
	{
		alert('店铺详细地址不能为空');
		return false;
	}
	
	if(dp_content == '')
	{
		alert('店铺简介不能为空');
		return false;
	}
	
	
	return true;
	
}


function change_city(obj)
{
    var index=obj.selectedIndex;
    var sel_val = obj.options[index].value;
    if(sel_val == 0)
    {
        $("#city").html("<option value='0'>选择市</option>");
        $("#county").html("<option value='0'>选择县/区</option>");
    }
    else
    {
        $.post("{url:/mobile/getCityByProvince}",{'code':sel_val},function(result){
            $("#city").html(result);
            $("#county").html("<option value='0'>选择县/区</option>");
        });
    }

}


function change_county(obj)
{
    var index=obj.selectedIndex;
    var sel_val = obj.options[index].value;
    if(sel_val == 0)
    {
        //$("#city").html("<option value='0'>--市--</option>");
        $("#county").html("<option value='0'>选择县/区</option>");
    }
    else
    {
        $.post("{url:/mobile/getCountyByCity}",{'code':sel_val},function(result){
            $("#county").html(result);
        });
    }

}
</script>
</body>
</html>
